﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using BEPUphysics.Entities.Prefabs;

namespace EventFlowLibrary.LevelComponents
{
    internal sealed class DynamicModel : BaseModel
    {

        /// <summary>
        /// Our dynamic physics model
        /// </summary>
        internal ConvexHull PhysicsModel { get { return physicsModel; } }
        private ConvexHull physicsModel;

        /// <summary>
        /// Mass of the object
        /// </summary>
        internal float Mass { get { return mass; } }
        private float mass;

        /// <summary>
        /// Whether the object casts a shadow in the game world.
        /// </summary>
        internal bool DisplayShadow { get { return displayShadow; } }
        private bool displayShadow;

        /// <summary>
        /// Bepu mass offsets for the position of a convex hull cause visual display problems. This is a fix.
        /// </summary>
        internal Vector3 MassOffset { get { return massOffset; } }
        private Vector3 massOffset;

        /// <summary>
        /// Construct the static model.
        /// </summary>
        /// <param name="_staticModel">The model to display.</param>
        /// <param name="_worldMatrix">The world matrix for the model.</param>
        internal DynamicModel(string _id, Model _model, ConvexHull _physicsModel, float _mass, Vector3 _position, Vector3 _scale, Vector3 _rotation, Vector3 _massOffset, bool _displayShadow)
            : base(_id, _model, _scale, _rotation, _position)
        {
            physicsModel = _physicsModel;
            mass = _mass;
            massOffset = _massOffset;
            //worldMatrix = Matrix.CreateScale(_scale) *
            //              Matrix.CreateRotationX(_rotation.X) * Matrix.CreateRotationY(_rotation.Y) * Matrix.CreateRotationZ(_rotation.Z) *
            //              Matrix.CreateTranslation(_position);
            displayShadow = _displayShadow;

            //physicsModel.WorldTransform = worldMatrix;
        }
    }
}
